﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FraudLabsProUtils;

namespace FraudLabsProExample
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //Create fraud object
            FraudLabsPro oFLP = new FraudLabsPro(txtAPIKey.Text);

            //Add the input params
            oFLP.flpRequest.ipAddress = txtIPAddress.Text;
            oFLP.flpRequest.shippingAddress = txtShippingAddress.Text;
            oFLP.flpRequest.shippingZIPCode = txtShippingPostalCode.Text;
            oFLP.flpRequest.shippingCity = txtShippingCity.Text;
            oFLP.flpRequest.shippingState = txtShippingRegion.Text;
            oFLP.flpRequest.shippingCountry = txtShippingCountry.Text;
            oFLP.flpRequest.billingZIPCode = txtBillingPostalCode.Text;
            oFLP.flpRequest.billingCity = txtBillingCity.Text;
            oFLP.flpRequest.billingState = txtBillingRegion.Text;
            oFLP.flpRequest.billingCountry = txtBillingCountry.Text;
            oFLP.flpRequest.creditCardNumber = txtCreditCardNumber.Text;
            oFLP.flpRequest.paymentMode = "creditcard";
            oFLP.flpRequest.amount = txtAmount.Text;
            oFLP.flpRequest.currency = "USD";

            //do the fraud validation
            oFLP.fraudCheck();

            //get the result
            txtResult.Text = "IP Country: " + oFLP.flpResponse.ipCountry + "\n" +
                             "IP Region: " + oFLP.flpResponse.ipRegion + "\n" +
                             "IP City: " + oFLP.flpResponse.ipCity + "\n" +
                             "Is IP a proxy: " + oFLP.flpResponse.isProxyIpAddress + "\n" +
                             "Is Billing-Shipping Country Match: " + oFLP.flpResponse.isBillShipCountryMatch + "\n" +
                             "Is Shipping a Ship Forwarded Address: " + oFLP.flpResponse.isAddressShipForward + "\n" +
                             "Is High Risk Country: " + oFLP.flpResponse.isHighRiskCountry + "\n" +
                             "Is BIN valid: " + oFLP.flpResponse.isBinFound + "\n" +
                             "Is Prepaid Card: " + oFLP.flpResponse.isBinPrepaid + "\n" +
                             "Fraud Score: " + oFLP.flpResponse.fraudlabsproScore;
        }
    }
}